package com.zork.cmdb.webapi.api;

import com.zork.cmdb.webapi.common.exception.CmdbException;
import com.zork.cmdb.webapi.common.response.ResponseEntityEnum;
import com.zork.cmdb.webapi.domain.vo.ModuleAttributesVO;
import com.zork.cmdb.webapi.service.ModuleAttributesService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chenjh
 * @date 2018/5/15
 * @description
 */
@RestController
@RequestMapping("/moduleAttributes")
public class ModuleAttributesController {

    @Autowired
    private ModuleAttributesService moduleAttributesService;

    @ApiOperation(value = "根据模型id获取属性列表", notes = "根据模型id获取属性列表")
    @ApiImplicitParam(name = "moduleID", value = "模型ID", required = true, dataType = "Integer")
    @GetMapping("/{moduleID}")
    public ResponseEntityEnum listAttributes(@PathVariable Integer moduleID) throws CmdbException {
        List<ModuleAttributesVO> moduleAttributesVOList = moduleAttributesService.listAttributes(moduleID);
        ResponseEntityEnum result = ResponseEntityEnum.SUCCESS.setData(moduleAttributesVOList);
        return result;
    }
}
